#!/usr/bin/python
# -*- coding: UTF-8 -*-

from email.mime.text import MIMEText
from email.header import Header
import smtplib


#qq邮箱smtp服务器
host_server = 'smtp.qq.com'
#sender_qq为发件人的qq号码
sender_qq = '912345678'
#pwd为qq邮箱的授权码
#获取授权码方法https://jingyan.baidu.com/article/b0b63dbf1b2ef54a49307054.html
pwd = 'iiiiffff'
#发件人的邮箱
sender_qq_mail = '912345678@qq.com'



def QQsendMail(mail_title,mail_content,receiver):
    # ssl登录
    smtp = smtplib.SMTP(host_server)
    # set_debuglevel()是用来调试的。参数值为1表示开启调试模式，参数值为0关闭调试模式
    smtp.set_debuglevel(1)
    smtp.ehlo(host_server)
    smtp.login(sender_qq, pwd)

    msg = MIMEText(mail_content, "plain", 'utf-8')
    msg["Subject"] = Header(mail_title, 'utf-8')
    msg["From"] = sender_qq_mail
    msg["To"] = receiver
    smtp.sendmail(sender_qq_mail, receiver, msg.as_string())
    smtp.quit()
